package com.sline.exception;

public class Demo3_Exception {
    public static void main(String[] args) {
        // demo1();

        int a = 10;
        int b = 0;
        int[] arr = {11, 22, 33, 44, 55};

        // jdk7如何处理多个异常
        try {
            //System.out.println(a / b);

            //System.out.println(arr[10]);

            arr = null;
            System.out.println(arr[0]);
        } catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
            System.out.println("除数不能为零");
        }
    }

    private static void demo1() {
        int a = 10;
        int b = 0;
        int[] arr = {11, 22, 33, 44, 55};

        try {
            //System.out.println(a / b);

            //System.out.println(arr[10]);

            arr = null;
            System.out.println(arr[0]);
        } catch (ArithmeticException e) {
            System.out.println("除数不能为零");
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("数组索引越界了");
        } catch (Exception e) {
            System.out.println("出错了");
        }
    }
}
